/*
 * @Description: 农资管理，不是农资类别管理
 */
import zhreq from "@/api/axios";
import zhreqtwo from "@/api/axios";
import zh from "@/lang/zh";
import { getToken } from "@/utils/auth";
export default {
  /**
   * @description: 获取所有农资表格列表 *代表必填
   * @param {String/Number} page *
   * @param {String/Number} size *
   */
  getTableDataList(params) {
    return zhreq.post("/v3/inputs/inputsRecord/queryPageByCondition", {
      ...params
    });
  },
  /**
   * @description:模糊查询农资表格列表 *代表必填
   */
  getqueryList(params) {
    return zhreq.post("/v3/templateTenant/material/queryByCondition", {
      // auditFlag: 1,
      ...params,
      organizationNo: sessionStorage.organizationNo
    });
  },
  /**
  * @description:模糊查询农资图片列表 *代表必填
  */
  getqueryImgList(params) {
    return zhreq.post("/agriculturalMaterial/queryByCondition", {
      auditFlag: 1,
      agriculturalMaterialNameLike: params
    });
  },
  /**
   * @description: 添加农资数据
   * @param {Object}  *
   */
  addmeslist(params) {
    return zhreq.post('/v3/inputs/inputsRecord/add', {
      ...params,
      "farmingTypeNo": sessionStorage.farmingTypeNo,
      organizationNo: sessionStorage.organizationNo
    });
  },
  // whw
  addMesList(params) {
    return zhreq.post('/v3/inputs/inputsRecord/addByFacilityNoToBatchNoList', {
      ...params,
      "farmingTypeNo": sessionStorage.farmingTypeNo,
      organizationNo: sessionStorage.organizationNo
    });
  },
  /**
  * @description: 添加农资数据
  * @param {Object}  *
  */
  editmeslist(params) {
    params.entity = {
      "farmingTypeNo": sessionStorage.farmingTypeNo
    }
    let zhenpar = {
      ...params
    }
    return zhreq.post('/v3/inputs/inputsRecord/edit', zhenpar);
  },
  /**
  * @description: 删除农资数据
  * @param {Object}  *
  */
  delmeslist(params) {
    let zhenpar = {
      ...params,
      "farmingTypeNo": sessionStorage.farmingTypeNo,
      organizationNo: sessionStorage.organizationNo
    }
    return zhreq.post('/v3/inputs/inputsRecord/delListByNo', zhenpar);
  },
  //   获取图片
  getimage(pictureNo) {
    return zhreqtwo.get(`/v3/inputs/picture/queryByNo?no=${pictureNo}`);
  },
  // 上传图片
  uploadImage(params) {
    let formData = new FormData();
    formData.append('multipartFile', params.multipartFile);
    formData.append('no', params.inputsRecordNo);
    const serviceTicket = getToken("token");
    let config = {
      headers: {
        'Content-Type': 'multipart/form-data',
        'Authorization': serviceTicket
      },
      onUploadProgress: (progressEvent) => {
        console.log(progressEvent);
      }
    };
    console.log(formData, 'uploadImage');
    return zhreqtwo.post(`/v3/inputs/picture/add`, formData, config);
  },
  /**
  * @description: 获取所有肥药双减列表 *代表必填
  * @param {String/Number} page *
  * @param {String/Number} size *
  */
  getMaterialInputList(params) {
    let zhenpar = {
      ...params
    }
    return zhreq.post("v3/inputs/inputsRecord/queryPageByCondition", zhenpar);
  },
  /**
  * @description: 获取批次名称 *代表必填
  * @param {String/Number} page *
  * @param {String/Number} status *是否已完成
  */
  queryBatchListName(params) {
    return zhreq.post('/v3/batch/productionBatch/queryByCondition', {
      ...params,
      "farmingTypeNo": sessionStorage.farmingTypeNo,
      organizationNo: sessionStorage.organizationNo
    })
  },
  queryBatchList(param) {
    return zhreq.post('/v3/batch/productionBatch/queryByCondition', {
      ...param,
      farmingTypeNo: sessionStorage.farmingTypeNo,
      organizationNo: sessionStorage.organizationNo,
    })
  },
  // 获取某个批次的详细信息
  getbatchfaclist(id) {
    return zhreq.get(`/v3/batch/productionBatch/findFacilityByBatchNo?no=${id}`)
  },
  /**
  * @description: 获取设施名称 *代表必填
  * @param {String/Number} page *
  * @param {String/Number} size *
  */
  queryFacilityListName() {
    return zhreq.post(`v3/facility/facility/queryByCondition`, { facilityStatus: 0 });
  },
  queryFacilityName() {
    return zhreqtwo.post("v3/facility/facility/queryByCondition", {
      organizationList: sessionStorage.getItem("organizationList").split(','),
      facilityStatus: 1
    })
  },
  /**
  * @description: 获取农资名称 *代表必填
  * @param {String/Number} page *
  * @param {String/Number} size *
  */
  queryagriculturalMaterialListName() {
    return zhreq.get(`/agriculturalMaterialInput/queryAgriculturalMaterial`);
  },

  // 查询部门
  getDepartmentList() {
    return zhreq.post(`/v3/organization/department/queryByCondition`, {
      organizationNo: sessionStorage.organizationNo
    });
  },
  // 查询岗位
  getPostList(no) {
    return zhreq.post(`/v3/organization/post/queryByCondition`, {
      departmentNo: no,
      organizationNo: sessionStorage.organizationNo
    });
  },
  // // 查询员工
  // getEmployeeList(no) {
  //   return zhreq.post("/v3/organization/personDepartmentMapper/queryUserByCondition", {
  //     postNo: no,
  //     organizationNo: sessionStorage.organizationNo
  //   });
  // },
  // 查询员工 暂时修改
  getEmployeeList(no) {
    return zhreq.post("/v3/organization/personDepartmentMapper/queryByCondition", {
      postNo: no,
      organizationNo: sessionStorage.organizationNo
    });
  },
  // 根据地块获取批次
  accordPlotGetBatch(params) {
    return zhreq.get(`/v3/batch/productionBatch/findByFacilityNoAndStatus?no=${params.no}&batchStatus=${params.batchStatus}`);
  },
  // 根据地块获取批次 多个
  findByFacilityNos(params) {
    return zhreq.get(`/v3/batch/productionBatch/findByFacilityNos?no=${params.no}`);
  },
  // 获取编号
  getNOList(no) {
    return zhreq.get(`v3/batch/productionBatch/queryByNo?no=${no}&isEliminate=false`)
  },
  // TODO:单个添加
  addmessingle(params) {
    params.farmingTypeNo = sessionStorage.farmingTypeNo
    // params.organizationNo = sessionStorage.organizationNo
    let zhenpar = { ...params }
    return zhreq.post('/v3/agriculturalTask/agriculturalTask/addSingleTask', zhenpar);
  },
};

